﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FeeFrm.aspx.cs" Inherits="WebApp.FeeFrm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>费用信息</title>
    <link rel="stylesheet" type="text/css" href="css/newStyle.css" />
    <link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.3.2/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.3.2/themes/icon.css" />

    <script type="text/javascript" src="js/common.js"></script>

    <script type="text/javascript" src="js/jquery-easyui-1.3.2/jquery-1.8.0.min.js"></script>

    <script type="text/javascript" src="js/jquery-easyui-1.3.2/jquery.easyui.min.js"></script>

    <script type="text/javascript">
        var PageSize = 20;
        //页面加载
        $(window).load(function() {
            initData();
            initGrid();
        });

        $(window).resize(function() {
            $('#tb').datagrid('resize');
        });

        function doSearch(pageNumber) {
            if (pageNumber > 0)
                pageNumber = pageNumber - 1; //从0开始
            var params = getParams(pageNumber);
            $('#tb').datagrid('reload', params);
        }


        function getParams(pageNumber) {
            return $.extend({}, {
                DataType: 'QFee',
                isVerify: $('#qVerify').val(),
                orderCode: $('#qOrderCode').val(),
                feeCode: $('#qFeeCode').val(),
                sDate: $('#qSDate').datebox('getValue'),
                eDate: $('#qEDate').datebox('getValue'),
                orderStatus: $('#qOrderStatus').combobox('getValue'),
                op: $('#qOperator').combogrid('getValue'),
                bizMan: $('#qBizMan').combogrid('getValue'),
                feeType: $('#qFeeType').combobox('getValue'),
                item: $('#qItem').combobox('getValue'),
                pageSize: PageSize,
                pageIndex: pageNumber
            });
        }

        function booleanFormat(val, rec) {
            if (val == true) {
                return "是";
            }
            else {
                if (val == false)
                    return "否";
                else
                    return val;
            }
        }

        //加载表格datagrid
        function initGrid() {

            var params = getParams(0);

            //加载数据
            $('#tb').datagrid({
                //toolbar: '#searchBar',
                width: 'auto',
                fit: true,
                fitColumns: true,
                height: 'auto',
                striped: true,
                singleSelect: true,
                url: 'JSONHandler.ashx',
                //url: 'JSONHandler.ashx?DataType=Order&deleteFlag=&orderCode=&cCode=&sDate=&eDate=&orderStatus=&agent=&bizMan=&stowageMethod=&clientName=&isDrawback=&customsStatus=&checkOffCode=&caseCode=&pageSize=' + pSize + '&pageIndex=' + pIndex,
                queryParams: params,
                loadMsg: '数据加载中请稍后……',
                pagination: true,
                rownumbers: true,
                columns: [[
        { field: 'Id', title: '编号', align: 'center', hidden: true },
        { field: 'FeeTypeId', title: '费用类型Id', hidden: true },
        { field: 'OrderId', title: '工作单编号', align: 'center', hidden: true },
        { field: 'OrderCode', title: '作业单号', align: 'center' },
        { field: 'OrderStatus', title: '流程状态', align: 'center' },
        { field: 'BizMan', title: '业务员id', align: 'center', hidden: true },
        { field: 'BizName', title: '业务员', align: 'center' },
        { field: 'FeeType', title: '费用类型', align: 'center' },
        { field: 'IsVerify', title: '审批', align: 'center', formatter: booleanFormat },
        { field: 'Item', title: '费目名称id', align: 'center', hidden: true },
        { field: 'ItemName', title: '费目名称', align: 'center' },
        { field: 'FeeCode', title: '账单号', align: 'center' },
        { field: 'Operator', title: '制单人id', align: 'center', hidden: true },
        { field: 'OperatorName', title: '制单人', align: 'center' },
        { field: 'Amount', title: '金额', align: 'center' },
        { field: 'Unit', title: '币制id', align: 'center', hidden: true },
        { field: 'UnitName', title: '币制', align: 'center' },
        { field: 'OPTime', title: '制单时间', align: 'center', formatter: Common.DateFormatter }
    ]], onDblClickRow: function(rowIndex, rowData) {
        editFee();
    }, loadFilter: function(data) {
        if (data)
            return data;
        else
            return { "total": 0, "rows": [] };
    }
            });

            $('#tb').datagrid('getPager').pagination({
                pageSize: PageSize, //每页显示的记录条数，默认为10   
                pageList: [10, 20, 30, 40, 50], //可以设置每页记录条数的列表   
                beforePageText: '第', //页数文本框前显示的汉字   
                afterPageText: '页    共 {pages} 页',
                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',
                onBeforeRefresh: function() {
                },
                onRefresh: function(pageNumber, pageSize) {
                },
                onChangePageSize: function(pageSize) {
                    PageSize = pageSize;
                },
                onSelectPage: function(pageNumber, pageSize) {
                    doSearch(pageNumber);
                }
            });

        }

        function initData() {
            $('#qSDate').datebox('setValue', DateFormatter(new Date().DateAdd('m', -1)));
            $('#qEDate').datebox('setValue', DateFormatter(new Date()));
            $('#qOrderStatus').combobox('reload', 'JSONHandler.ashx?DataType=OrderStatus');

            $.getJSON("JSONHandler.ashx?DataType=User", function(result) {
                $('#qOperator').combogrid("grid").datagrid("loadData", result);
                $('#qBizMan').combogrid("grid").datagrid("loadData", result);
            });

            $.getJSON("JSONHandler.ashx?DataType=FeeType", function(result) {
                $('#qFeeType').combobox('loadData', result);
            });
        }

        function resetAll() {
            $('#fm').form('clear');
        }

        function editFee() {
            var row = $('#tb').datagrid('getSelected');
            if (row) {
                var orderId = row.OrderId;
                var feeId = row.Id;
                var feeType = row.FeeTypeId;
                if (feeId)
                    openWin('EditFeeFrm.aspx?FeeType=' + feeType + '&OrderId=' + orderId + '&FeeId=' + feeId, "编辑费用", 600, 400);
            }
        }

        function openWin(url, title, width, height) {
            $('#winFrame').prop('src', url);
            $('#winFrame').prop('style').height = height + 'px';
            $('#winFrame').prop('style').width = width + 'px';
            $('#win').window({
                title: title,
                width: width + 'px',
                height: height + 'px',
                modal: true
            });
        }      
    </script>

</head>
<body style="padding: 5px">
    <form id="form1" runat="server">
    </form>
    <div class="easyui-layout" fit="true">
        <div data-options="region:'north'" style="padding: 5px;">
            <form id="fm" style="padding: 0; margin: 0">
            <span>制单时段：</span>
            <input id="qSDate" class="easyui-datebox" data-options="formatter:DateFormatter,parser:DateParser"
                style="width: 90px" />至
            <input id="qEDate" class="easyui-datebox" style="width: 90px" />
            <span>流程状态：</span><input class="easyui-combobox" id="qOrderStatus" data-options="valueField:'Value',textField:'Name'"
                style="width: 90px;">
            <span>制单人：</span><input class="easyui-combogrid" id="qOperator" style="width: 100px"
                data-options="  
            panelWidth: 100,  
            idField: 'id',  
            textField: 'userName',
            columns: [[   
                {field:'userName',title:'名称',width:100}               
            ]],  
            fitColumns: true  
        ">
            <span>业务员：</span><input class="easyui-combogrid" id="qBizMan" style="width: 100px"
                data-options="  
            panelWidth: 100,  
            idField: 'id',  
            textField: 'userName',
            columns: [[   
                {field:'userName',title:'名称',width:100}               
            ]],  
            fitColumns: true  
        "><br />
            <br />
            <span>费用类型：</span>
            <input class="easyui-combobox" id="qFeeType" data-options="valueField:'Value',textField:'Name'"
                style="width: 70px;">
            <span>是否审核：</span><select class="easyui-combobox" id="qVerify" style="width: 60px;">
                <option value="">所有</option>
                <option value="1">是</option>
                <option value="0">否</option>
            </select>
            <span>费目名称：</span><input class="easyui-combobox" id="qItem" data-options="valueField:'id',textField:'name'"
                style="width: 100px;">
            <span>作业号：</span><input type="text" style="width: 100px" id="qOrderCode">
            <span>账单号：</span><input type="text" style="width: 100px" id="qFeeCode">
            <br />
            <br />
            <a href="#" class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="doSearch(0);">
                搜索</a> <a href="#" class="easyui-linkbutton" iconcls="icon-undo" plain="true" onclick="resetAll();">
                    重置</a></form>
        </div>
        <div data-options="region:'center'" style="position: relative;">
            <table id="tb" class="easyui-datagrid">
            </table>
        </div>
    </div>
    <div id="win">
        <iframe id="winFrame" src="" style="width: 0px; height: 0px" frameborder="0" scrolling="no">
        </iframe>
    </div>
</body>
</html>
